home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / Swiftsoft Multimedia Tools / MMTOOL3.EXE / MMMixReg.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-05-07  |  13.4 KB  |  328 lines

  1. {========================================================================}
  2. {=                (c) 1995-98 SwiftSoft Ronald Dittrich                 =}
  3. {========================================================================}
  4. {=                          All Rights Reserved                         =}
  5. {========================================================================}
  6. {=  D 01099 Dresden             = Tel.: +0351-8012255                   =}
  7. {=  Loewenstr.7a                = info@swiftsoft.de                     =}
  8. {========================================================================}
  9. {=  Actual versions on http://www.swiftsoft.de/mmtools.html             =}
  10. {========================================================================}
  11. {=  This code is for reference purposes only and may not be copied or   =}
  12. {=  distributed in any format electronic or otherwise except one copy   =}
  13. {=  for backup purposes.                                                =}
  14. {=                                                                      =}
  15. {=  No Delphi Component Kit or Component individually or in a collection=}
  16. {=  subclassed or otherwise from the code in this unit, or associated   =}
  17. {=  .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed     =}
  18. {=  without express permission from SwiftSoft.                          =}
  19. {=                                                                      =}
  20. {=  For more licence informations please refer to the associated        =}
  21. {=  HelpFile.                                                           =}
  22. {========================================================================}
  23. {=  $Date: 20.01.1998 - 18:00:00 $                                      =}
  24. {========================================================================}
  25. unit MMMixReg;
  26.  
  27. {$I COMPILER.INC}
  28.  
  29. Interface
  30.  
  31. procedure Register;
  32.  
  33. Implementation
  34.  
  35. {$IFDEF WIN32}
  36. {$R MMMIXER.D32}
  37. {$ELSE}
  38. {$R MMMIXER.D16}
  39. {$ENDIF}
  40.  
  41. uses
  42.     Classes,
  43.     Controls,
  44.     DsgnIntf,
  45.     TypInfo,
  46.     SysUtils,
  47.     MMObj,
  48.     MMPropEd,
  49.     MMDevice,
  50.     MMMixer,
  51.     MMMixCtl,
  52.     MMMixBlk,
  53.     MMLevel,
  54.     MMMeter,
  55.     MMDesign,
  56.     MMCmpMan;
  57.  
  58. type
  59.     {-- TMMMixerComponentProperty ---------------------------------------}
  60.     TMMMixerComponentProperty = class(TComponentProperty)
  61.     private
  62.         FList : TStringList;
  63.         procedure AddToList(const S: string);
  64.     protected
  65.         function ValidComponent(C: TComponent): Boolean; virtual; abstract;
  66.     public
  67.         procedure GetValues(Proc: TGetStrProc); override;
  68.     end;
  69.  
  70.     {-- TMMMixerDeviceDeviceProperty ------------------------------------}
  71.     TMMMixerDeviceDeviceProperty = class(TMMMixerComponentProperty)
  72.     protected
  73.       function ValidComponent(C: TComponent): Boolean; override;
  74.     end;
  75.  
  76.     {-- TMMMixerLabelConnectorDestProperty ------------------------------}
  77.     TMMMixerLabelConnectorDestProperty = class(TMMMixerComponentProperty)
  78.     protected
  79.       function  ValidComponent(C: TComponent): Boolean; override;
  80.     end;
  81.  
  82.     {-- TMMAudioLineDestLineProperty ------------------------------------}
  83.     TMMAudioLineDestLineProperty    = class(TMMMixerComponentProperty)
  84.     protected
  85.         function ValidComponent(C: TComponent): Boolean; override;
  86.     end;
  87.  
  88.     {-- TMMControlIdProperty --------------------------------------------}
  89.     TMMControlIdProperty    = class(TMMIntegerProperty)
  90.     protected
  91.         procedure   GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt); override ;
  92.         procedure   GetConsts(List: TList); override ;
  93.     end;
  94.  
  95.     {-- TMMLineIdProperty -----------------------------------------------}
  96.     TMMLineIdProperty       = class(TMMIntegerProperty)
  97.     protected
  98.         procedure   GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt); override ;
  99.         procedure   GetConsts(List: TList); override ;
  100.     end;
  101.  
  102.     {-- TMMItemIndexProperty --------------------------------------------}
  103.     TMMItemIndexProperty    = class(TMMIntegerProperty)
  104.     protected
  105.         procedure   GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt); override ;
  106.         procedure   GetConsts(List: TList); override ;
  107.     end;
  108.  
  109. {== TMMMixerComponentEditor =============================================}
  110. procedure TMMMixerComponentProperty.AddToList(const S: string);
  111. begin
  112.    FList.Add(S);
  113. end;
  114.  
  115. {-- TMMMixerComponentEditor ---------------------------------------------}
  116. procedure TMMMixerComponentProperty.GetValues(Proc: TGetStrProc);
  117. var
  118.    i: Integer;
  119. begin
  120.    FList := TStringList.Create;
  121.    try
  122.       Designer.GetComponentNames(GetTypeData(GetPropType),AddToList);
  123.       for i := 0 to FList.Count - 1 do
  124.           if ValidComponent(Designer.GetComponent(FList[i])) then
  125.              Proc(FList[i]);
  126.    finally
  127.       FList.Free;
  128.    end;
  129. end;
  130.  
  131. {== TMMMixerDeviceDeviceProperty ========================================}
  132. function TMMMixerDeviceDeviceProperty.ValidComponent(C: TComponent): Boolean;
  133. begin
  134.    Result := (C is TMMCustomAudioDevice) and
  135.              ((C as TMMCustomAudioDevice).GetDeviceType <> dtMixer);
  136. end;
  137.  
  138. {== TMMMixerLabelConnectorDestProperty ==================================}
  139. function TMMMixerLabelConnectorDestProperty.ValidComponent(C: TComponent): Boolean;
  140. begin
  141.    Result := TypInfo.GetPropInfo(C.ClassInfo,'Caption') <> nil;
  142. end;
  143.  
  144. {== TMMAudioLineDestLineProperty ========================================}
  145. function    TMMAudioLineDestLineProperty.ValidComponent(C: TComponent): Boolean;
  146. begin
  147.     Result := (C is TMMAudioLine) and (C <> GetComponent(0)) ;
  148. end;
  149.  
  150. {== TMMControlIdProperty ================================================}
  151. procedure   TMMControlIdProperty.GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt);
  152. begin
  153.     IntToIdent := ControlIdToIdent;
  154.     IdentToInt := IdentToControlId;
  155. end;
  156.  
  157. {-- TMMControlIdProperty ------------------------------------------------}
  158. procedure TMMControlIdProperty.GetConsts(List: TList);
  159. begin
  160.     List.Add(Pointer(badControlId));
  161. end;
  162.  
  163. {== TMMLineIdProperty ===================================================}
  164. procedure   TMMLineIdProperty.GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt);
  165. begin
  166.     IntToIdent := LineIdToIdent ;
  167.     IdentToInt := IdentToLineId ;
  168. end;
  169.  
  170. {-- TMMLineIdProperty ---------------------------------------------------}
  171. procedure   TMMLineIdProperty.GetConsts(List: TList);
  172. begin
  173.     List.Add(Pointer(badLineId));
  174. end;
  175.  
  176. {== TMMItemIndexProperty ================================================}
  177. procedure   TMMItemIndexProperty.GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt);
  178. begin
  179.     IntToIdent := ItemIndexToIdent ;
  180.     IdentToInt := IdentToItemIndex ;
  181. end;
  182.  
  183. {-- TMMItemIndexProperty ------------------------------------------------}
  184. procedure   TMMItemIndexProperty.GetConsts(List: TList);
  185. begin
  186.     List.Add(Pointer(NoItem));
  187. end;
  188.  
  189. {========================================================================}
  190. function CheckMixDevice(C1, C2: TComponent): Boolean;
  191. begin
  192.    if (C1 is TMMCustomAudioDevice) then
  193.        Result := (C1 as TMMCustomAudioDevice).GetDeviceType <> dtMixer
  194.    else
  195.        Result := False;
  196. end;
  197.  
  198. {------------------------------------------------------------------------}
  199. function CheckSliderControl(C1, C2: TComponent): Boolean;
  200. begin
  201.    if (C1 is TMMCustomMixerControl) then
  202.        Result := (C1 as TMMCustomMixerControl).ControlClass in MixerSliderControlClasses
  203.    else
  204.        Result := False;
  205. end;
  206.  
  207. {------------------------------------------------------------------------}
  208. function CheckWheelControl(C1, C2: TComponent): Boolean;
  209. begin
  210.    if (C1 is TMMCustomMixerControl) then
  211.        Result := (C1 as TMMCustomMixerControl).ControlClass in MixerWheelControlClasses
  212.    else
  213.        Result := False;
  214. end;
  215.  
  216. {------------------------------------------------------------------------}
  217. function CheckSwitchControl(C1, C2: TComponent): Boolean;
  218. begin
  219.    if (C1 is TMMCustomMixerControl) then
  220.        Result := (C1 as TMMCustomMixerControl).ControlClass in SwitchControlClasses
  221.    else
  222.        Result := False;
  223. end;
  224.  
  225. {------------------------------------------------------------------------}
  226. function CheckConnectorControl(C1, C2: TComponent): Boolean;
  227. begin
  228.    if (C1 is TMMCustomMixerControl) then
  229.        Result := (C1 as TMMCustomMixerControl).ControlClass in ConnectorControlClasses
  230.    else
  231.        Result := False;
  232. end;
  233.  
  234. {------------------------------------------------------------------------}
  235. function CheckMixControl(C1, C2: TComponent): Boolean;
  236. begin
  237.    if (C1 is TMMCustomMixerControl) then
  238.        Result := (C1 as TMMCustomMixerControl).ControlClass = ccList
  239.    else
  240.        Result := False;
  241. end;
  242.  
  243. {------------------------------------------------------------------------}
  244. function CheckLabelDest(C1, C2: TComponent): Boolean;
  245. begin
  246.    Result := GetPropInfo(C2.ClassInfo,'Caption') <> nil;
  247. end;
  248.  
  249. {------------------------------------------------------------------------}
  250. function CheckItemLine(C1, C2: TComponent): Boolean;
  251. begin
  252.     if C1 is TMMAudioLine then
  253.         Result := cfSource in (C1 as TMMAudioLine).LineInfo.Flags
  254.     else
  255.         Result := False;
  256. end;
  257.  
  258. {------------------------------------------------------------------------}
  259. procedure Register;
  260. begin
  261. //   RegisterComponents('MMMixer',[TMMAudioDevice]);
  262.  
  263.    RegisterComponents('MMMixer',[TMMCompManager,
  264.                                  TMMMixerDevice,
  265.                                  TMMAudioLine,
  266.                                  TMMMixerControl,
  267.                                  TMMVolumeControl,
  268.                                  TMMPanControl,
  269.                                  TMMMixerSlider,
  270.                                  TMMMixerWheel,
  271.                                  TMMMixerCheckBox,
  272.                                  TMMMixerConnector,
  273.                                  TMMMixerLabelConnector,
  274.                                  TMMDeviceSpin,
  275.                                  TMMDeviceComboBox,
  276.                                  TMMMixerBlock,
  277.                                  TMMMixerBlockSlider,
  278.                                  TMMMixerBlockCheck,
  279.                                  TMMMixerBlockLevel,
  280.                                  TMMMixerBlockLabel
  281.                                  ]);
  282.  
  283.    RegisterPropertyEditor(TypeInfo(TMMCustomAudioDevice),TMMMixerDevice,'Device',TMMMixerDeviceDeviceProperty);
  284.    RegisterPropertyEditor(TypeInfo(TMMCustomAudioDevice),TMMAudioLine,'Target',TMMMixerDeviceDeviceProperty);
  285.    RegisterPropertyEditor(TypeInfo(TControl),TMMMixerLabelConnector,'Destination',TMMMixerLabelConnectorDestProperty);
  286.    RegisterPropertyEditor(TypeInfo(TMMComponent),TMMAudioLine,'DestLine',TMMAudioLineDestLineProperty);
  287.    RegisterPropertyEditor(TypeInfo(TMMControlId),nil,'',TMMControlIdProperty);
  288.    RegisterPropertyEditor(TypeInfo(TMMLineId),nil,'',TMMLineIdProperty);
  289.    RegisterPropertyEditor(TypeInfo(TMMItemIndex),nil,'',TMMItemIndexProperty);
  290.  
  291.    { Register the properties for TMMDesigner }
  292.    RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Device', TMMMixerDevice, CheckMixDevice);
  293.  
  294.    RegisterPropertyException(ptInput, 'Mixer', TMMMixerDevice, 'Device', TMMMixerDevice, nil);
  295.  
  296.    RegisterProperty(ptInput, 'Mixer', TMMMixerDevice, 'Mixer', TMMAudioLine, nil);
  297.    RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Target', TMMAudioLine, CheckMixDevice);
  298.  
  299.    RegisterPropertyException(ptInput, 'Mixer', TMMMixerDevice, 'Target', TMMAudioLine, nil);
  300.  
  301.    RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'DestLine', TMMAudioLine, nil);
  302.    RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'AudioLine', TMMCustomMixerControl, nil);
  303.  
  304.    RegisterProperty(ptOutput, 'Mixer', TMMPanControl, 'VolumeControl', TMMVolumeControl, nil);
  305.  
  306.    RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Control', TMMCustomMixerSlider, CheckSliderControl);
  307.    RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Control', TMMCustomMixerWheel, CheckWheelControl);
  308.    RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Control', TMMCustomMixerCheckBox, CheckSwitchControl);
  309.  
  310.    RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'ItemLine', TMMCustomMixerCheckBox, CheckItemLine);
  311.    RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Control', TMMCustomMixerConnector, CheckConnectorControl);
  312.    RegisterProperty(ptOutput, 'Mixer', TMMMixerConnector, 'Level1', TMMCustomLevel, nil);
  313.    RegisterProperty(ptOutput, 'Mixer', TMMMixerConnector, 'Level2', TMMCustomLevel, nil);
  314.    RegisterProperty(ptOutput, 'Mixer', TMMMixerConnector, 'Meter1', TMMCustomMeter, nil);
  315.    RegisterProperty(ptOutput, 'Mixer', TMMMixerConnector, 'Meter2', TMMCustomMeter, nil);
  316.  
  317.    RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Source', TMMMixerLabelConnector, nil);
  318.    RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'Source', TMMMixerLabelConnector, nil);
  319.    RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Source', TMMMixerLabelConnector, nil);
  320.    RegisterProperty(ptOutput, 'Mixer', TMMMixerLabelConnector, 'Destination', TControl, CheckLabelDest);
  321.    RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Device', TMMDeviceSpin, nil);
  322.    RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Device', TMMDeviceComboBox, nil);
  323.    RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'Line', TMMMixerBlock, nil);
  324.    RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Mixer', TMMMixerBlock, CheckMixControl);
  325. end;
  326.  
  327. end.
  328.